import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test2 {
    public static void main(String[] args) {
        Collection coll = new ArrayList();

        coll.add("abc");
        coll.add(new Person("张三", 18));
        coll.add(123);

        Iterator iterator = coll.iterator();

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

    }
}

class Person {
    String name;

    int age;

    public Person() {
        this(" ", 0);
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "姓名: " + this.name + ",年龄: " + this.age;
    }
}